/* =================================================
 * Package:			dk.iha.toksEditor
 * File:			JSON.java
 * Description:		A simple class to convert a input 
 * 					to a JSONArray
 * 
 * Responsible
 * =================================================
 * Name:			Bjarke Jensen
 * Study number:	09676
 */
package dk.iha.toksEditor;

import java.io.BufferedReader;

import org.json.JSONArray;
import org.json.JSONObject;

public class JSON {
	
	/**
	 * Converts the input to a JSONArray
	 * 
	 * @param in BufferedStream Input to convert. 
	 * @return {@link JSONArray} A JSONArray containing the input.
	 */
	static public JSONArray unJSON(BufferedReader in)
	{

        JSONArray ar = new JSONArray();
        JSONObject ob = new JSONObject();
        String line = "";
		try 
		{
			line = in.readLine();
			ar = new JSONArray(new String(line));
		}
		catch (Exception e)
		{
			
			String g = line;
			try
			{
				ob = new JSONObject(line);
				ar.put(ob);
			}
			catch (Exception ex) {
				ex.printStackTrace();
			}
			e.printStackTrace();
		}
		return ar;
	}

}
